﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using YYFDebugTools.CommonHelper;
using YYFDebugTools.ViewModels;

namespace YYFDebugTools.ViewWinPages
{
    /// <summary>
    /// ImageOptions.xaml 的交互逻辑
    /// </summary>
    public partial class ImageOptions : Window
    {
        public ImageOptionsVM OptionVM { get; set; }
        public ImageOptions()
        {
            InitializeComponent();
            OptionVM = new ImageOptionsVM();
            this.DataContext = OptionVM;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ImageOptionsSet optionsSet = new ImageOptionsSet(null);
            optionsSet.Owner = this;
            if (optionsSet.ShowDialog() == true)
            {
                OptionVM.ImageOptionsSetVMs.Add(optionsSet.OptionVM);
            }
        }

        private void UpData(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
            var setVM = btn?.DataContext as ImageOptionsSetVM;
            if (setVM != null)
            {
                ImageOptionsSet optionsSet = new ImageOptionsSet(setVM);
                optionsSet.Owner = this;
                optionsSet.ShowDialog();
            }

        }

        private void addFile(object sender, RoutedEventArgs e)
        {
            if (SelectFiels.OpenSelectFileDialog(out List<string>? selectFile) && selectFile != null)
            {
                foreach (var item in selectFile)
                {
                    OptionVM.InputImages.Add(new InputImage(item));
                }
            }
        }

        private void DisDTFile(object sender, RoutedEventArgs e)
        {
            OptionVM.DisDatas();
        }
    }
}
